package com.ss.android.article.base.ui;

import android.content.Context;
import android.graphics.Bitmap;
import android.util.AttributeSet;
import android.view.ViewGroup;
import android.widget.ImageView;

public class AdjustImageView extends ImageView {
    private Bitmap a;
    private int b;
    private int c;
    private boolean d;
    private boolean e;

    public AdjustImageView(Context arg1) {
        super(arg1);
        this.a();
    }

    public AdjustImageView(Context arg2, AttributeSet arg3) {
        this(arg2, arg3, 0);
    }

    public AdjustImageView(Context arg1, AttributeSet arg2, int arg3) {
        super(arg1, arg2, arg3);
        this.a();
    }

    private void a() {
        this.d = true;
        if(this.e) {
            this.b();
            this.e = false;
        }
    }

    private void b() {
        if(!this.d) {
            this.e = true;
        }
        else if(this.a != null) {
            this.c = this.a.getHeight();
            this.b = this.a.getWidth();
            this.invalidate();
        }
    }

    public void setImageBitmap(Bitmap arg11) {
        super.setImageBitmap(arg11);
        this.a = arg11;
        this.b();
        int v2 = this.getResources().getDisplayMetrics().widthPixels;
        if(v2 > 0) {
            int v3 = this.c;
            int v4 = this.b;
            double v0 = 1;
            if(v3 != 0 && v4 != 0) {
                v0 = (((double)v2)) / (((double)v4));
                if((((double)v3)) * v0 > (((double)v2))) {
                    v0 = (((double)v2)) / (((double)v3));
                }
            }

            v2 = ((int)((((double)v3)) * v0));
            int v0_1 = ((int)(v0 * (((double)v4))));
            ViewGroup.LayoutParams v1 = this.getLayoutParams();
            v1.width = v0_1;
            v1.height = v2;
            this.setLayoutParams(v1);
        }
    }
}

